package com.labo.erpcrm.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;

import com.labo.erpcrm.bean.Commande;

public class CommandeDao extends GenericRepository<Commande, Integer> {
	
	public Commande GetById(Integer Id){
		Session s = HelperSessionFactory.getSession();
		Transaction trans = s.beginTransaction();
		Criteria criteria = s.createCriteria(Commande.class).add(Restrictions.eq("id_commande", Id));
		Commande commande = (Commande) criteria.uniqueResult();
		trans.commit();
		return commande;
	}	

	@SuppressWarnings("unchecked")
	public List<Commande> GetAll(){
		Session s = HelperSessionFactory.getSession();
		Transaction trans = s.beginTransaction();
		Criteria criteria = s.createCriteria(Commande.class);
		List<Commande> lstCommande = (List<Commande>) criteria.list();
		trans.commit();
		return lstCommande ;
	}

	@Override
	public void Save(Commande obj) {
		// TODO Auto-generated method stub
		super.Save(obj);
	}

	@Override
	public void SaveOrUpdate(Commande obj) {
		// TODO Auto-generated method stub
		super.SaveOrUpdate(obj);
	}

	@Override
	public void Update(Commande obj) {
		// TODO Auto-generated method stub
		super.Update(obj);
	}

	@Override
	public void Delete(Commande obj) {
		// TODO Auto-generated method stub
		super.Delete(obj);
	}

}
